# 异常发生后，打印异常堆栈信息到文件中

import traceback

try:
    b = 0
    c = a / b
    print(c)
except Exception as e:
    # 方式一
    msg = traceback.format_exc()
    with open("1.log", "wb") as file:
        file.write(msg.encode(encoding="utf-8"))

